(deftemplate animale
    (slot nume)
    (slot mediuViata)
    (slot modViata)
    (slot regimAlimentar)
    (slot zona)
    (slot mancatorDE)
    (slot mancatDE)
)

(assert (animale (nume foca)(mediuViata acvatic)(modViata diurn)(regimAlimentar omnivor)
    (zona polara)(mancatorDE pesti)(mancatDE urs)))
(assert (animale (nume urs)(mediuViata semiacvatic)(modViata diurn)(regimAlimentar omnivor)
    (zona polara)(mancatorDE foca)(mancatDE tigru)))
(assert (animale (nume soarece)(mediuViata terestru)(modViata diurn)(regimAlimentar omnivor)
    (zona mediteraneana)(mancatorDE branza)(mancatDE pisica)))
(assert (animale (nume rechin)(mediuViata acvatic)(modViata diurn)(regimAlimentar carnivor)
    (zona polara)(mancatorDE pesti)(mancatDE balena)))
(assert (animale (nume oaie)(mediuViata terestru)(modViata diurn)(regimAlimentar omnivor)
    (zona balcanica)(mancatorDE iarba)(mancatDE lup)))
(assert (animale (nume tigru)(mediuViata terestru)(modViata diurn)(regimAlimentar carnivor)
    (zona deserturilor)(mancatorDE lupi)(mancatDE leu)))
(assert (animale (nume lup)(mediuViata terestru)(modViata diurn)(regimAlimentar carnivor)
    (zona mediteraneana)(mancatorDE capre)(mancatDE leu)))
(assert (animale (nume ornitorinc)(mediuViata semiacvatic)(modViata nocturn)(regimAlimentar carnivor)
    (zona mediteraneana)(mancatorDE viermi)(mancatDE caini_dingo)))
(assert (animale (nume pisica)(mediuViata terestru)(modViata diurn)(regimAlimentar omnivor)
    (zona mediteraneana)(mancatorDE lapte)(mancatDE tigru)))

(printout t "**************************************************************" crlf)
(run)
(defrule rule1
    (declare (salience 31))
    (animale (nume ?n)(mediuViata semiacvatic))
    
    => 
    (printout t "Animalul " ?n " traieste intr-un mediu semiacvatic." crlf)
 )

(printout t "**************************************************************" crlf)
(run)
(defrule rule2
    (declare (salience 22))
    (animale (nume ?n)(regimAlimentar ierbivor)(zona mediteraneana))
    
    => 
    (printout t "Animalul " ?n " este ierbivor si traieste intr-un zona mediteraneana." crlf)
 )

(printout t "**************************************************************" crlf)
(run)
(defrule rule3a
    (declare (salience 13))
    (animale (nume ?n)(mancatorDE ?x))
        
    => 
    (printout t "(" ?n ", " ?x ")"crlf)
 )

(printout t "**************************************************************" crlf)
(run)
(defrule rule3b
    (declare (salience 6))
    (animale (nume ?n)(mancatDE ?x))
        
    => 
    (printout t "(" ?x ", " ?n ")"crlf)
 )

(printout t "**************************************************************" crlf)
(run)
(defrule rule4
    (declare (salience 5))
    (animale (nume ?n)(zona ?z &~mediteraneana & ~deserturilor)) 
        
    => 
    (printout t "Animalul " ?n " traieste intr-o zona polara" crlf)
 )

(facts)
(printout t "**************************************************************" crlf)
(run)